const obj = {
  foo: 'foo',
  bar: {
    baz: 'baz'
  },
  arr: []
}

function render() {
  console.log('render')
}

const handler = {
  get(target, key) {
    if (typeof target[key] === 'object' && target[key] !== null) {
      return new Proxy(target[key], handler)
    }
    return Reflect.get(target, key)
  },
  set(target, key, value) {
    if (key === 'length') return true
    render()
    return Reflect.set(target, key, value)
  }
}

const p = new Proxy(obj, handler)

// p.bar.baz = 'bazzz'
// p.arr[1] = 111
p.arr.push(777)
console.log(p)
